package com.example.myapplication.utils;

import android.content.Intent;

import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.example.myapplication.MyApp;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class AspectCheckLogin {
    @Pointcut("execution(@com.example.myapplication.utils.CheckLogin * *(..))")
    private void check(){}
    @Around("check()")
    private void around(ProceedingJoinPoint point) throws Throwable {
        String token = SPUtils.getInstance().getString("token");
        if(token.isEmpty()){
            ToastUtils.showLong("未登录去登录");
            /*MyApp.getContext().startActivity(new Intent(MyApp.getContext(),LoginActivity.class));*/
            SPUtils.getInstance().put("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIsImV4cCI6MTcyMDQyNjMzOSwidXNlcm5hbWUiOiIxNTIzMTI4MjY2NyJ9.saxsSJZuHXfGFPsbFpdQDGrndLmue4bHiBXr3yP70Os");
        }else {
            point.proceed();
        }
    }
}
